package com.control.qct.businesssteward.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.control.qct.businesssteward.R;
import com.control.qct.businesssteward.activity.TheCargoDetailActivity;
import com.control.qct.businesssteward.adapter.MyTheCargoAdapter;
import com.control.qct.businesssteward.base.BaseFragment;
import com.control.qct.businesssteward.entity.TabEntity;
import com.control.qct.businesssteward.model.MyTheCargoModel;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 被调拨管理
 * Created by Administrator on 2018/1/16 0016.
 */

public class TheCargoManagementFragment extends BaseFragment implements OnTabSelectListener {

    @BindView(R.id.ctl_the_cargo_management_top)
    CommonTabLayout mCtlTheCargoManagementTop;
    @BindView(R.id.rv_the_cargo_management)
    RecyclerView mRvTheCargoManagement;

    private final String[] mTitles = {"全部", "待回应", "已同意", "已拒绝"};
    private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
    private List<MyTheCargoModel> mMyTheCargoModelList;
    private MyTheCargoAdapter mMyTheCargoAdapter;
    private Bundle mBundle;

    @Override
    protected View initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle
            savedInstanceState) {
        return inflater.inflate(R.layout.fragment_the_cargo_management, container, false);
    }

    @Override
    protected void initView(View view) {
        mBundle = new Bundle();
        mBundle.putInt("id", 2);
        for (int i = 0; i < mTitles.length; i++) {
            mTabEntities.add(new TabEntity(mTitles[i], 0, 0));
        }
        mCtlTheCargoManagementTop.setTabData(mTabEntities);
        mCtlTheCargoManagementTop.setOnTabSelectListener(this);
        setReplenishmentListBeanList();
        mRvTheCargoManagement.setLayoutManager(new LinearLayoutManager(activity));
        mMyTheCargoAdapter = new MyTheCargoAdapter(mMyTheCargoModelList);
        mRvTheCargoManagement.setAdapter(mMyTheCargoAdapter);
        mMyTheCargoAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                startActivity(TheCargoDetailActivity.class, mBundle);
            }
        });
    }

    private void setReplenishmentListBeanList() {
        mMyTheCargoModelList = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            mMyTheCargoModelList.add(new MyTheCargoModel(i));
        }
    }


    @Override
    public void onTabSelect(int position) {

    }

    @Override
    public void onTabReselect(int position) {

    }
}
